#include <iostream>
#include<stdio.h>
#include<sys/time.h>
#include<unistd.h>
#include<arm_neon.h>
using namespace std;

const int s = 100;
float A[s][s];

void Gauss(int n) {
	for (int k = 1; k <= n ; k++) {
		for (int j = k+1; j <= n; j++) {
			A[k][j] /= A[k][k];
		}
		A[k][k] = 1.0;
		for (int i = k + 1; i <= n; i++) {
			for (int j = k + 1; j <= n; j++) {
				A[i][j] -= A[i][k] * A[k][j];
			}
			A[i][k] = 0;
		}
	}

}
void GaussSIMD(int n) {
	for (int k = 1; k <= n; k++) {
		float32x4_t vt = vmovq_n_f32(A[k][k]);
		for (int j = k + 1; j <= n; j+=4) {
			if (j + 3 > n) {
				while (j <= n) {
					A[k][j] /= A[k][k];
					j++;
				}
			}
			else{
				float32x4_t var = vld1q_f32(A[k] + j);
				var = vmulq_f32(var, vt);
				vst1q_f32(A[k] + j, var);
			}
			A[k][k] = 1.0;
		}
		A[k][k] = 1.0;
		for (int i = k + 1; i <= n; i++) {
			for (int j = k + 1; j+4 <= n; j+=4) {
				if (j + 3 > n) {
					while (j <= n) {
						A[i][j] -= A[i][k] * A[k][j];
						j++;
					}
				}
				else {
					float32x4_t v1 = vld1q_f32(A[i] + j);
					float32x4_t v2 = vld1q_f32(A[k] + j);
					float32x4_t v3 = vld1q_f32(A[i] + k);
					v2 = vmulq_f32(v3, v2);
					v1 = vsubq_f32(v1, v2);
					vst1q_f32(A[i] + j, v1);
				}
			}
			A[i][k] = 0;
		}
	}
}

int main()
{
	int N;
	cin >> N;
	for (int i = 1; i <= N; i++)
	{
		for (int j = 1; j < i; j++)
			A[i][j] = 0;
		A[i][i] = 1.0;
		for (int j = i + 1; j < N; j++)
			A[i][j] = rand();
		}
	for (int k = 0; k < N; k++)
		for (int i = k + 1; i < N; i++)
			for (int j = 0; j < N; j++)
				A[i][j] += A[k][j];
	for (int i = 1; i <= N; i++) {
		for (int j = 1; j <= N; j++) {
			cout << A[i][j] << "  ";
		}
		cout << endl;
	}
	cout << endl;

	struct  timeval  tv_begin, tv_end;
	gettimeofday(&tv_begin, NULL);
	for (int i = 0; i < 10; i++) {
		GaussSIMD(N);
		//Gauss(N);
	}
	gettimeofday(&tv_end, NULL);
	double time = (tv_end.tv_sec - tv_begin.tv_sec) * 1000000 + (tv_end.tv_usec - tv_begin.tv_usec);
	time /= 10;

	for (int i = 1; i <= N; i++) {
		for (int j = 1; j <= N; j++) {
			cout << A[i][j] << "  ";
		}
		cout << endl;
	}

	cout << time;
	return 0;
}



